﻿#ifndef __AF_DEBUG_H__
#define __AF_DEBUG_H__

#include "AF_Log.h"

#ifdef AF_HASTRY
#define AF_TRY				try
#define AF_CATCH(_EType, _pE)		catch(_EType, _pException)
#define AF_CATCHALL()			catch(...)
#else
#define AF_TRY				if(1 == 0)
#define AF_CATCH(_EType, _pE)		if(1 == 0)
#define AF_CATCHALL()			if(1 == 0)
#endif

#ifdef AF_DEBUG
#define AF_ASSERT(f) \
	if((int)(f) == 0) \
	{ \
		AF_ERROR("Assert <"#f##"> is FALSE!", ""); \
		return; \
	}
#define AF_ASSERT_R(f, r) \
	if((int)(f) == 0) \
	{ \
		AF_ERROR("Assert <"#f##"> is FALSE!", ""); \
		return r; \
	}

///// 断言
//// 确定表达式一定成立，否则返回
//#define AF_ASSERT(f)			if((f) == false){return;}
///// 断言
//#define AF_ASSERT_R(f, r)		if((f) == false){return r;}


#else /*AF_DEBUG*/
#define AF_ASSERT(f)
#define AF_ASSERT_R(f, r)
#endif /*AF_DEBUG*/

// 如果表达式不成立则返回
/// 检查
#define AF_CHECK(f) \
	if((int)(f) == 0) \
	{ \
		AF_LOG("Check <"#f##"> is FALSE!", ""); \
		return; \
	}
/// 检查
#define AF_CHECK_R(f, r) \
	if((int)(f) == 0) \
	{ \
		AF_LOG("Check <"#f##"> is FALSE!", ""); \
		return r; \
	}


#endif